package d.j;

import d.h.a.a;
import d.h.b.c;

class g extends f {
    public static final <T, A extends Appendable> A a(a<? extends T> aVar, A a2, CharSequence charSequence, CharSequence charSequence2, CharSequence charSequence3, int i, CharSequence charSequence4, a<? super T, ? extends CharSequence> aVar2) {
        c.c(aVar, "$this$joinTo");
        c.c(a2, "buffer");
        c.c(charSequence, "separator");
        c.c(charSequence2, "prefix");
        c.c(charSequence3, "postfix");
        c.c(charSequence4, "truncated");
        a2.append(charSequence2);
        int i2 = 0;
        for (Object next : aVar) {
            i2++;
            if (i2 > 1) {
                a2.append(charSequence);
            }
            if (i >= 0 && i2 > i) {
                break;
            }
            e.a(a2, next, aVar2);
        }
        if (i >= 0 && i2 > i) {
            a2.append(charSequence4);
        }
        a2.append(charSequence3);
        return a2;
    }

    public static final <T> String b(a<? extends T> aVar, CharSequence charSequence, CharSequence charSequence2, CharSequence charSequence3, int i, CharSequence charSequence4, a<? super T, ? extends CharSequence> aVar2) {
        c.c(aVar, "$this$joinToString");
        c.c(charSequence, "separator");
        c.c(charSequence2, "prefix");
        c.c(charSequence3, "postfix");
        c.c(charSequence4, "truncated");
        StringBuilder sb = new StringBuilder();
        a(aVar, sb, charSequence, charSequence2, charSequence3, i, charSequence4, aVar2);
        String sb2 = sb.toString();
        c.b(sb2, "joinTo(StringBuilder(), …ed, transform).toString()");
        return sb2;
    }

    public static /* synthetic */ String c(a aVar, CharSequence charSequence, CharSequence charSequence2, CharSequence charSequence3, int i, CharSequence charSequence4, a aVar2, int i2, Object obj) {
        if ((i2 & 1) != 0) {
            charSequence = ", ";
        }
        CharSequence charSequence5 = "";
        CharSequence charSequence6 = (i2 & 2) != 0 ? charSequence5 : charSequence2;
        if ((i2 & 4) == 0) {
            charSequence5 = charSequence3;
        }
        int i3 = (i2 & 8) != 0 ? -1 : i;
        if ((i2 & 16) != 0) {
            charSequence4 = "...";
        }
        CharSequence charSequence7 = charSequence4;
        if ((i2 & 32) != 0) {
            aVar2 = null;
        }
        return b(aVar, charSequence, charSequence6, charSequence5, i3, charSequence7, aVar2);
    }

    public static <T, R> a<R> d(a<? extends T> aVar, a<? super T, ? extends R> aVar2) {
        c.c(aVar, "$this$map");
        c.c(aVar2, "transform");
        return new h(aVar, aVar2);
    }
}
